import cn.cvs.dao.config.SpringConfig;
import cn.cvs.dao.supper.SupperMapper;
import cn.cvs.pojo.Supplier;
import cn.cvs.pojo.SysUser;
import cn.cvs.service.supper.SupperService;
import cn.cvs.service.uservice.UserService;
import cn.cvs.service.uservice.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;



public class TestSelect {
    @Test
    public void sysUserAdd() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService service = (UserService) context.getBean(UserService.class);
        SysUser sysUser = new SysUser();
        sysUser.setAccount("test001");
        sysUser.setRealName("测试用户001");
        sysUser.setPassword("1234567");
        sysUser.setBirthday(new Date());
        sysUser.setAddress("测试地址abc");
        sysUser.setSex(1);
        sysUser.setPhone("13411110000");
        sysUser.setRoleId(1);
        sysUser.setCreatedUserId(1);
        sysUser.setCreatedTime(new Date());
        int result = service.AddSysUserResult(sysUser);
        System.out.println("testAdd result :" + result);
    }

    @Test
    public void sysUserDelete() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService service = (UserService) context.getBean(UserService.class);
        int count = service.deleteSysUser(36);
        System.out.println("===================================" + count);
    }

    @Test
    public void sysUserUpdate() {
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService service = (UserService) context.getBean(UserService.class);
        SysUser sysUser = new SysUser();
        sysUser.setId(1);
        sysUser.setPassword("2123121");
        int count = service.updateSysUser(sysUser);
        System.out.println("===================================" + count);
    }

    @Test
    public void SupperAdd() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        SupperService service = (SupperService) context.getBean(SupperService.class);
        Supplier supplier = new Supplier();
        supplier.setSupCode("sdfsdf");
        supplier.setSupName("王东阳小牛发展有限公司");
        supplier.setSupDesc("主营产品：洗衣皂、洗衣粉、洗衣液、");
        supplier.setSupContact("小王");
        supplier.setSupPhone("13245468787");
        supplier.setSupAddress("山东济阳济北工业区仁和街21号");
        supplier.setSupFax("0531-53362445");
        supplier.setCreatedUserid(2);
        supplier.setCreatedTime(new Date());
        int count = service.addSupper(supplier);
        System.out.println("======================"+count);
    }

    @Test
    public void SupplierDel() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        SupperService service = (SupperService) context.getBean(SupperService.class);
        int result = service.delSupplier(42);
        System.out.println("==============="+result);
    }
}
